package com.badibadi.mytools;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;

import com.badibadi.uniclubber.R;

public class MyDiaglogInterface {

	OnMyDiaglogInterClickListener myDiaglogInterClickListener;
	Context context;
	  int itemNum=0;
	public MyDiaglogInterface(Context context)
	{
		this.context=context;
	}
	/**
	 * 单选框
	 * @param items
	 * @return 返回数组选中项
	 */
	public void singleChoice(String[] items)
	{
		
		AlertDialog.Builder builder=new AlertDialog.Builder(context)
		.setTitle(R.string.PleaseChose_)
		.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				itemNum=which;
//				   
			}
		}).setNegativeButton(context.getString(R.string.Cancle),new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				itemNum=-1;
				myDiaglogInterClickListener.cancle(itemNum);
			}
		}).setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				myDiaglogInterClickListener.ok(itemNum);
				
			}
		});
		builder.show();
		
	}
	public void setOnMyDiaglogInterClickListener(OnMyDiaglogInterClickListener listener)
	{
		myDiaglogInterClickListener=listener;
	}
	public interface OnMyDiaglogInterClickListener{
		void ok(int itemNum);
		void cancle(int itemNum);
	}
}
